<template>
  <div class="toast-container">
    <div v-for="m in messages" :key="m.id" :class="['toast', `toast--${m.type}`]">
      <span class="toast__icon">{{ iconMap[m.type] }}</span>
      <span class="toast__text">{{ m.text }}</span>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useToastStore } from '@/stores/toast'

const toast = useToastStore()
const messages = computed(() => toast.messages)
const iconMap = {
  success: '✅',
  error: '❌',
  warning: '⚠️',
  info: 'ℹ️'
}
</script>

<style scoped>
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  color: #fff;
  font-size: 14px;
}
.toast__icon { font-size: 16px; }
.toast--success { background: #4caf50; }
.toast--error { background: #f44336; }
.toast--warning { background: #ff9800; }
.toast--info { background: #2196f3; }
</style>